package com.doit.day01

import java.util.Scanner
import scala.util.Random

object _05_if {
  def main(args: Array[String]): Unit = {
    //猜数字小游戏
    val random: Random = new Random()
    val target: Int = random.nextInt(100)
    //不断地判断   有5次机会，猜对他
    val sc: Scanner = new Scanner(System.in)
    var cnt = 5
    while (cnt > 0){
      val guss: Int = sc.nextInt()
      if (guss == target){
        println("猜对了")
        //需要结束代码   循环的中断
        return
      }else if(guss > target){
        println("猜大了")
      }else{
        println("猜小了")
      }
      cnt -= 1
    }



  }
}
